
/**
 * LoginBean.java

 * 
 */

package com.example.managedbeans;

import java.util.List;


import com.example.entities.*;
import com.example.service.*;




public class LoginBean
{
    private String name;
    private String password;


    public String getName ()
    {
        return name;
    }


    public void setName (final String name)
    {
        this.name = name;
    }


    public String getPassword ()
    {
        return password;
    }


    public void setPassword (final String password)
    {
        this.password = password;
    }
    
    public String authenticate()
    {   
    	UserHandler userHandler = new UserHandler();
    	List<User> users = userHandler.getAllUsers();
    	for (User user : users) {
    		if(user.getPassword().equals(this.password)&&user.getUserName().equals(this.name))
    	//	if(user.getPassword().equals(this.password)&&user.getUserName().equals(this.name))
    		{
    			return "success";   		
    		}
		}
    	return "failure";

    	

    }
    
 
}
